<?php
/**
 * @link http://www.yincart.com/
 * @copyright Copyright (c) 2014 Yincart
 * @license http://www.yincart.com/license/
 */

use yii\helpers\Html;
use backend\models\AdminUser;

$admin=Yii::$app->user->identity;

?>

<style type="text/css" media="all">
    body{background: #3C8DBC;font-family: 微软雅黑}
    .logo-box{width: 220px;height:100%;background:#367FA9;float:left;}
    .logo{float:left;}
    ul li{float:left;height:50px;line-height: 50px;text-align: center;margin-right: 35px;list-style:none;color:#D8E8F2;}
    ul li a{display: block;color:#D8E8F2;text-decoration:none;outline:none;}
    ul li a:hover{color:#fff;text-decoration:none;}
    ul li.cur a{color:#fff;font-weight:bold;margin-top:-2px;font-size:16px;}
    .name{float:left;margin-right: 10px;}
    #menu{float:left;}
    .hiddenLeft{float:left;margin-top: 8px;margin-left: 8px;cursor:pointer;}

    .logout{float: right;margin-right: 20px;}
    .logout a{margin-left: 15px;}
    
     .system-select{height:50px;line-height: 50px;margin-left:30px;}
</style>


<div class="logo-box">
    <div class="logo"></div>
    <span style="height:50px;line-height:50px;color:#fff;font-weight:bold;font-size:20px;">乐麦地管理系统</span>
</div>

<div class="hiddenLeft" onclick="parent.hiddenLeft();" title="隐藏左边栏"></div>
<ul id="menu">
    <?php foreach ($admin->getMenu() as $key => $item): ?>
        <li>
            <?=Html::a($item['name'],['page','type'=>'left','key'=>$key],['target'=>'leftFrame','onFocus'=>'this.blur();'])?>
        </li>
    <?php endforeach; ?>
</ul>

<?php
$system=$admin->getSystems();

$systemMap=[
    AdminUser::TYPE_PLATFROM=>'总后台',
    AdminUser::TYPE_SUPPLIER=>'供应商系统',
    AdminUser::TYPE_DELIVERY=>'配送中心',
];

?>

<?php if(!empty($system)):?>
<div class="system-select">
    <select id="systemSelect">
    <?php foreach ($system as $val):?>
        <option value="<?=$val?>" <?php if($val==$admin->currentSystem){echo 'selected';}?> data-url="<?=  yii\helpers\Url::to(['set-system','type'=>$val]);?>"><?=$systemMap[$val]?></option>
    <?php endforeach;?>
    </select>
</div>
<?php endif;?>

<script>
window.onload=function(){
    $('#systemSelect').change(function(){
        top.location.href = $('#systemSelect option:selected').attr('data-url');
    });
};
</script>


